package org.gd.jms.rabbitmq;

import java.util.Locale;

public class Main {

    public static final String INPUT_QUEUE_NAME = "TestQueue399";
    public static final String OUTPUT_QUEUE_NAME = "TestQueue1";

    public static void main(String...args) throws InterruptedException {
        //frame = new RabbitMQSenderFrame();
        /*frame.print("print 1");
        frame.print("print 2");
        frame.print();
        frame.print("print 3");
        frame.print("print 4");*/



        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.printf(new Locale("UA"), "[addShutdownHook]: totalMemory: %,d\n", Runtime.getRuntime().totalMemory());
                System.out.printf(new Locale("UA"), "[addShutdownHook]: maxMemory:   %,d\n", Runtime.getRuntime().maxMemory());
                System.out.printf(new Locale("UA"), "[addShutdownHook]: freeMemory:  %,d\n", Runtime.getRuntime().freeMemory());
            }
        }));
        rabbitTest();
    }

    private static void rabbitTest() {
        System.out.println("Hello RabbitMQ Getter Client!");
        try {
            new Thread(new RabbitMQGetter(INPUT_QUEUE_NAME)).start();
            new Thread(new RabbitMQSender(INPUT_QUEUE_NAME)).start();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.out.println("Goodbye RabbitMQ Getter Client!");
            /*System.exit(0);*/
        }
    }

}
